<?php get_instance()->view('common/header');?>
<div class="page-container home">
    <?php get_instance()->view('common/sidebar');?>
    <div class="page-content-wrapper">
        <div class="page-content">
            <div class="row">
                <div class="col-md-12">
                    <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                    <h3 class="page-title"> <?php echo $title ?> </h3>
                    <ul class="page-breadcrumb breadcrumb">
                        <li><i class="fa fa-home"></i><a href="javascript:void(0);"><?php echo $title ?> </a></li>
                    </ul>
                    <!-- END PAGE TITLE & BREADCRUMB-->
                </div>
            </div>
            <!--开始-->
            <div class="row">
                <div class="col-md-12">
                    <div class="portlet">
                        <div class="portlet-body">
                            <div class="table-container">
                                <div class="table-actions-wrapper"> <span> </span>
                                    <?php if(adminAuthority('merchantCash-export', 'fund')):?>
                                        <a class="btn btn-sm blue add export" href="javascript:;"><i class="fa fa-download"></i> 导出</a>
                                    <?php endif;?>
                                </div>
                                <table class="table table-bordered table-hover scoll-title" id="datatable">
                                    <thead>
                                    <tr role="row" class="heading">
                                        <th sort="false">ID</th>
                                        <th sort="false">商户</th>
                                        <th sort="false">提现方式</th>
                                        <th sort="false">金额</th>
                                        <th sort="false">完成时间</th>
                                        <th sort="false">添加时间</th>
                                        <th width="100px" sort="false">状态</th>
                                        <th width="120px" sort="false">操作</th>
                                    </tr>
                                    <tr>
                                        <th></th>
                                        <th><input class="form-control form-filter input-sm" name="keyword" type="text" placeholder="请输入用户名或手机号码"></th>
                                        <th>
                                            <select name="pay_type" class="form-control form-filter input-sm">
                                                <option value="0" selected>所有</option>
                                                <option value="2">微信</option>
                                                <option value="3">支付宝</option>
                                                <option value="4">银行卡</option>
                                            </select>
                                        </th>
                                        <th><input class="form-control form-filter input-sm" name="amount" type="tel"></th>
                                        <th>
                                            <div class="margin-bottom-5">
                                                <input class="form-control form-filter input-sm" name="confirm_time_from" dp placeholder="从" type="text">
                                            </div>
                                            <input class="form-control form-filter input-sm" name="confirm_time_to" dp placeholder="到" type="text" >
                                        </th>
                                        <th>
                                            <div class="margin-bottom-5">
                                                <input class="form-control form-filter input-sm" name="addtime_from" dp placeholder="从" type="text">
                                            </div>
                                            <input class="form-control form-filter input-sm" name="addtime_to" dp placeholder="到" type="text" >
                                        </th>
                                        <th>
                                            <select name="found_status" class="form-control form-filter input-sm">
                                                <option value="0" selected>所有</option>
                                                <?php foreach ($status as $k => $v):?>
                                                <option value="<?php echo $k?>"><?php echo $v?></option>
                                                <?php endforeach;?>
                                            </select>
                                        </th>
                                        <th>
                                            <div class="btn-group">
                                                <a class="btn btn-xs filter-submit btn-default"><i class="fa fa-search"></i> 搜索</a>
                                                <button data-toggle="dropdown" class="btn btn-default dropdown-toggle btn-xs" type="button"><i class="fa fa-angle-down"></i></button>
                                                <ul role="menu" class="dropdown-menu pull-right">
                                                    <li><a href="javascript:void(0);" class="filter-cancel">重置</a></li>
                                                </ul>
                                            </div>
                                        </th>
                                    </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--结束-->
        </div>
    </div>
</div>
<div id="save-modal" style="top: 20%;" class="modal fade modal_small" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title">拒绝打款理由</h4>
            </div>
            <form action="<?php echo getUrl('fund/merchantCash/changeStatus');?>" class="form-horizontal" id="save-form" method="get">
                <div class="modal-body">
                    <div class="form-group">
                        <label class="control-label col-md-2">拒绝理由<span class="required">*</span></label>
                        <div class="col-md-9">
                            <textarea  class="form-control required" name="reason" ></textarea>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <input type="hidden" name="id" value="">
                    <input type="hidden" name="status" value="1">
                    <button class="btn green">保存</button>
                    <button class="btn default" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> 关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        var model = $('#save-modal');

        $('.edit-btn').live('click', function(){
            var id = $(this).attr('data-id');
            model.find('[name="id"]').val(id);
            model.find('[name="reason"]').val('');
            model.find('.has-error').removeClass('has-error').find('.validate_message').remove();
            model.find('.show_message_error').remove();
            model.modal();
        });
        $.e_validate.init('#save-form',{modal:model,ignore:'',successCallback:function(data){
            $('#datatable').dataTable().fnDraw();
        }});
    });
</script>
<script type="text/javascript">
    $(function(){
        datatable_init({
            src: $("#datatable"),
            sAjaxSource: "<?php echo getUrl('fund/merchantCash/getList');?>",
            bSort:false
        });

        $('[dp]').not("[noinit]").datepicker({
            changeMonth: true,
            autoclose: true,
            format: "yyyy-mm-dd",
            language: 'zh-CN'
        });

        $(".export").on('click',function () {
            var addtime_from = $("[name='addtime_from']").val();
            var addtime_to = $("[name='addtime_to']").val();
            var confirm_time_from = $("[name='confirm_time_from']").val();
            var confirm_time_to = $("[name='confirm_time_to']").val();
            var found_status = $("[name='found_status']").val();
            var amount = $("[name='amount']").val();
            var pay_type = $("[name='pay_type']").val();
            var keyword = $("[name='keyword']").val();
            var url = '';
            if(addtime_from.length){
                url = 'addtime_from='+addtime_from;
            }
            if(addtime_to.length){
                url += '&addtime_to='+addtime_to;
            }
            if(confirm_time_from.length){
                url += '&confirm_time_from='+confirm_time_from;
            }
            if(confirm_time_to.length){
                url += '&confirm_time_to='+confirm_time_to;
            }
            if(found_status.length){
                url += '&found_status='+found_status;
            }
            if(amount.length){
                url += '&amount='+amount;
            }
            if(pay_type.length){
                url += '&pay_type='+pay_type;
            }
            if(keyword.length){
                url += '&keyword='+keyword;
            }
//                if (url.indexOf('&') == 0){
//                    url = url.substr(1,url.length);
//                }
            if (url.indexOf('&') == 0){
                url = url.substr(1,url.length);
            }
            if(url.length){
                window.location.href="<?php echo getUrl('fund/merchantCash/export')?>?"+url;
            }else{
                window.location.href="<?php echo getUrl('fund/merchantCash/export')?>";
            }
        })
    });
</script>
</body>
</html>